package edu.hawaii.halealohacli;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
import org.wattdepot.client.WattDepotClient;

/**
 * Test class for bad user inputs to RankTowers command.
 * 
 * @author John MacMillan
 * @author Mitchell Kupfer
 * @author Bryson Hori
 * 
 */
public class TestRankTowers {

  private String command1;
  // private String command2;
  // private String command3;
  // private String command4;
  private String command5;
  private String command6;
  private String command7;
  private String command8;
  private String command9;
  private String command10;

  protected boolean test;

  /**
   * Default constructor.
   */
  public TestRankTowers() {
    command1 = "2011-11-23";
    // command2 = "2011-11-23";

    // command3 = "2011-11-23";
    // command4 = "2011-11-23";

    command5 = "1800-02-03";
    command6 = "1800-03-04";

    command7 = "XNBJ";
    command8 = "JHGD";

    command9 = "2010-05-02";
    command10 = "2010-05-01";

  }

  /**
   * Tests rank-towers ability to handle bad/good input and give the used feedback on why an error
   * has occurred.
   * 
   * @throws Exception if an error occurs.
   */
  @Test
  public void testInput() throws Exception {
    boolean value = true;

    String url = "http://server.wattdepot.org:8190/wattdepot/";

    // Create a WattDepotClient with URL
    WattDepotClient client = new WattDepotClient(url);

    /*
     * try { RankTowers t1 = new RankTowers(command1, command1, client); value = t1.run(); } catch
     * (Exception e) { value = false; }
     */

    try {
      RankTowers t2 = new RankTowers(command1, command1, client);
      value = t2.run();
    }
    catch (Exception e) {
      value = false;
    }

    assertTrue("Test good rank-tower commands", value);

    try {
      RankTowers t3 = new RankTowers(command5, command6, client);
      value = t3.run();
    }
    catch (Exception e) {
      value = false;
    }

    try {
      RankTowers t4 = new RankTowers(command7, command8, client);
      value = t4.run();
    }
    catch (Exception e) {
      value = false;
    }

    try {
      RankTowers t5 = new RankTowers(command9, command10, client);
      value = t5.run();
    }
    catch (Exception e) {
      value = false;
    }

    command9 = null;
    command10 = null;

    try {
      RankTowers t6 = new RankTowers(command9, command10, client);
      value = t6.run();
    }
    catch (Exception e) {
      value = false;
    }

    assertFalse("Test bad rank-tower commands", value);
  }
}
